export function isNumber(num:any) {
    return !isNaN(num) && (typeof num === 'number')
}

export function getTime() : number{
    return Math.floor((new Date()).getTime() / 1000)
}

export function successReturn(data:any = null, msg:string = '请求成功', statusCode:number = 200) {
    return {
        success : true,
        data,
        msg,
        statusCode
    }
  }
  
  export function errorReturn(msg:string = '请求失败', statusCode:number = 400, data:any = null) {
    return {
        success : false,
        data,
        msg,
        statusCode
    }
  }

  export function createOrderNo(userId:number) {
    const date = new Date()
    const time = Math.floor(date.getTime() / 1000) % 1000000
    const year = date.getFullYear() % 100
    const month = String(date.getMonth() + 1).padStart(2, '0')
    const day = String(date.getDate()).padStart(2, '0')
    return year + month + day + time + String(userId).padStart(10, '0')
  }